package com.dragon.sso.config;

import com.dragon.sso.ldap.LDAPConnector;
import com.novell.ldap.LDAPConnection;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@ConfigurationProperties(prefix = "oauth2.ldap")
@Data
public class LDAPConfiguration {
  private String host = "10.116.18.50";
  private Integer port = LDAPConnection.DEFAULT_PORT;
  private String bindDn = "shuang.yang@iquantex.com";
  private String bindPassword = "Shuang.123";
  private String baseDn = "ou=iquantex,dc=iquantex,dc=com";

  @Bean
  public LDAPConnector ldapConnector() {
    return LDAPConnector.builder()
        .defaultBindDn(bindDn)
        .defaultBindPwd(bindPassword)
        .baseDn(baseDn)
        .ldapHost(host)
        .ldapPort(port)
        .build();
  }
}
